define(() => {
    return function (now,price) {
        let goods = localStorage.getItem("goods") ? JSON.parse(localStorage.getItem("goods")) : [];

        if (goods.length < 1) {
            goods.push({
                id: now.parent().attr("id"),
                num:1,
                check:false,
                price: price,
            })
        } else {
            let i = 0;
            const f = goods.some((val, idx) => {
                i = idx;
                return val.id === now.parent().attr("id");
            })
            if (f) {
                goods[i].num++;
            } else {
                goods.push({
                    id: now.parent().attr("id"),
                    num: 1,
                    check: false,
                    price: price,
                })
            }
        }
        localStorage.setItem("goods", JSON.stringify(goods));
    }
})